package com.example.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/7/28 15:32
 */
public class FastJsonUtils {
    private FastJsonUtils() {}

    public static <T> T parseObject(String body, String target, Class<T> clazz) {
        JSONObject parse = (JSONObject) JSONObject.parse(body);
        return parse.getObject(target, clazz);
    }

    public static String objectToString(Object source) {
        return JSON.toJSONStringWithDateFormat(source, "yyyy-MM-dd HH:mm:ss",
                SerializerFeature.WriteDateUseDateFormat);
    }

}
